package com.yh.util;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Map;

public class BaseAction extends ActionSupport {

    /**
     * 获得request
     * @return
     */
    public HttpServletRequest getRequest() {
        return ServletActionContext.getRequest();
    }


    /**
     * map Session
     * @return
     */
     public Map<String,Object> getMapSession(){
        return ActionContext.getContext().getSession();
    }
    /**
     * 获得session
     * @return
     */
    public HttpSession getSession() {
        return ServletActionContext.getRequest().getSession();
    }

    /**
     * 获得response
     * @return
     */
    public HttpServletResponse getResponse(){
        HttpServletResponse response= ServletActionContext.getResponse();
        response.setContentType("text/html;charset=UTF-8");
        return response ;
    }


}
